import paramiko

# k = paramiko.RSAKey.from_private_key_file("/Users/whatever/Downloads/mykey.pem")
# print "connected"
# commands = ["/home/ubuntu/firstscript.sh", "/home/ubuntu/secondscript.sh"]
# for command in commands:
#     print "Executing {}".format(command)
#     stdin, stdout, stderr = c.exec_command(command)
#     print stdout.read()
#     print("Errors")
#     print stderr.read()
# c.close()

HOST = {
    'jump': {
        'host': '10.10.217.214',
        'user': 'root',
        'pass': 'irerQdh49nZNqfcMGVc9Jmlcjtik4qE4De1oNQQ2ewOK3X1z7pqxpjXNd4aWLmNI',
    },
    'hk.jump': {
        'host': '23.248.162.92',
        'user': 'root',
        'pass': '',
        'identityFile': 'jump.sendclou.io-id_rsa.pub'
    }
}

params = HOST['jump']
jump_server = paramiko.SSHClient()
jump_server.set_missing_host_key_policy(paramiko.AutoAddPolicy())
jump_server.connect(params['host'], username=params['user'], password=params['pass'])
stdin, stdout, stderr = jump_server.exec_command('LANG=en ls -al /root/')
print(stdout.read())
transport = jump_server.get_transport()

params = HOST['hk.jump']
jump_server_hk = paramiko.SSHClient()
jump_server_hk.set_missing_host_key_policy(paramiko.AutoAddPolicy())
jump_server_hk.connect(params['host'], username=params['user'], password=params['pass'], sock=)
stdin, stdout, stderr = jump_server.exec_command('LANG=en ls -al /root/')

# vmtransport = vm.get_transport()
# dest_addr = ('10.103.53.26', 22)  # edited#
# local_addr = ('192.168.115.103', 22)  # edited#
# vmchannel = vmtransport.open_channel("direct-tcpip", dest_addr, local_addr)
# #
# jhost = paramiko.SSHClient()
# jhost.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# #jhost.load_host_keys('/home/osmanl/.ssh/known_hosts') #disabled#
# jhost.connect('10.103.53.26', username='latiu',
#               password='xxxx', sock=vmchannel)
# #
# stdin, stdout, stderr = jhost.exec_command("show version | no-more")  # edited#
# #
# print stdout.read()  # edited#
# #
# jhost.close()
# vm.close()
